/*
 * StackChar.c
 *
 *  Created on: Jan 29, 2012
 *      Author: Georgios
 */

#include <stdio.h>
#include <string.h>
//#include <conio.h>

#include "StackPimitiveDataTypes.h"
#include "MyStack.h"

#define MAX_SIZE 21

int StackChar()
{
    stack_t mystack;
    stackElement_t *stackelem;

    char str[MAX_SIZE];
    char *traversechar;

    strcpy(str, "Jag kommer att testa");

    printf("\n");
    printf("\n---------------------------------\n");
    printf("\nStack Use - Char types\n");
    printf("\n---------------------------------\n");

    if (!StackInit(&mystack, strlen(str))) {
    	return 0;
    }

    printf("\nPushed elements are: ");
    for (traversechar = str; *traversechar != '\0'; traversechar++) {
		if (!StackPush(&mystack, traversechar)) {
			printf("\n Warning: Stack is full ");
		} else {
			printf("< %c >", *traversechar);
		}
    }


    printf("\nPopped elements are: ");

    while (!StackIsEmpty(&mystack)) {
    	stackelem = StackPop(&mystack);
    	traversechar = *stackelem;
    	if (NULL != stackelem) {
    		printf("< %c >", *traversechar);
    	}
    }

    StackDestroy(&mystack);

    return 0;
}
